1. /* sdominus.cpp by K.Tsuru */
  2. // function ID = 331 DRADIX
  3. /***************************************
  4. SDouble class
  5. It provides the subtraction operator-().
  6. It returns "m-n".
  7. ****************************************/
  8. #ifndef SN_H
  9. #include "sn.h"
  10. #endif
  11. SDouble operator-(const SDouble& m, const SDouble& n){
  12. if((m.Type() != m.REAL)||(n.Type() != n.REAL)) m.SetError(m.RADIX_ERR, "SD -", 331);
  13. int sgn = m.Sign(331)*n.Sign(331), c;
  14. if( sgn == 0 ){ //m and/or n =0
  15. if( m.Sign() == 0 ) return -n;
  16. else return m;
  17. } else if(sgn < 0){ //different sign m - n = m + (-n)
  18. return DDAdd(m, -n); //The sign is the same that of m, set in DDAdd().
  19. } else { //same sign
  20. c = DDCompare(m, n);
  21. if(c > 0) return DDSub(m, n); //|m|>|n|, The sign is same as that of m,set in DDSub().
  22. else if(c) return -DDSub(n, m); //|m|<|n|, m-n=-(n-m)
  23. else return 0.0; // c = 0 : m = n result = 0
  24. }
  25. }

sdominus.cpp : last modifiled at 2015/11/25 20:18:29(936 bytes)
created at 2017/10/07 10:21:14
The creation time of this html file is 2017/10/07 10:30:03 (Sat Oct 07 10:30:03 2017).